 package com.school.controller;

import java.io.File;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.servlet.http.HttpServletResponse;

import org.apache.commons.io.FilenameUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.school.entity.HljtClass;

import com.school.entity.HljtClassimage;
import com.school.entity.HljtClassnotify;
import com.school.entity.HljtClassschedulecard;
import com.school.entity.HljtDuty;
import com.school.entity.HljtEducation;
import com.school.entity.HljtGradetime;
import com.school.entity.HljtStudent;
import com.school.entity.HljtSubject;
import com.school.entity.HljtTeacher;
import com.school.entity.HljtTeacherclass;
import com.school.entity.android.ClassCurriculum;
import com.school.entity.android.ClassExcellent;
import com.school.entity.android.Images;
import com.school.entity.android.MoralEducation;
import com.school.entity.android.Teacher;
import com.school.entity.web.ClassImage;
import com.school.entity.web.ClassNotity;
import com.school.entity.web.ClassStudentImage;
import com.school.entity.web.ClasssCheduleCard;
import com.school.entity.web.HljtDeviceManagement;
import com.school.service.HljtClassService;
import com.school.service.HljtOtherInterfacesService;
import com.school.service.impl.HljtClassServiceIpml;
import com.school.service.impl.HljtClassimageServiceImpl;
import com.school.service.impl.HljtClassnotifyServiceImpl;
import com.school.service.impl.HljtClassschedulecardServiceImpl;
import com.school.service.impl.HljtStudentServiceImpl;
import com.school.service.impl.HljtSubjectServiceImpl;
import com.school.service.impl.HljtTeacherServiceImpl;
import com.school.service.impl.HljtTeacherclassServiceImpl;
import com.school.service.impl.HljtEducationSerivceImpl;
import com.school.service.impl.HljtGradetimeServiceImpl;
import com.school.service.impl.HljtDutySerivceImpl;
import com.school.util.JsonInterface;
import com.school.util.Message;
import com.school.util.RepUtil;
import com.school.util.WhetherNotToUpdate;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

@Controller
public class HljtClassController {
	
	
	@Autowired
	private HljtClassService hljtClassService;
	@Autowired
	private HljtTeacherServiceImpl hljtTeacherServiceImpl;
	@Autowired
	private HljtTeacherclassServiceImpl hljtTeacherclassServiceImpl;
	@Autowired
	private HljtStudentServiceImpl hljtStudentServiceImpl;
	@Autowired
	private HljtClassnotifyServiceImpl hljtClassnotifyServiceImpl;
	@Autowired
	private HljtClassServiceIpml hljtClassServiceIpml;
	@Autowired
	private HljtClassimageServiceImpl hljtClassimageServiceImpl;
	@Autowired
	private HljtClassschedulecardServiceImpl hljtClassschedulecardServiceImpl;
	@Autowired
	private HljtEducationSerivceImpl hljtEducationSerivceImpl;
	@Autowired
	private HljtDutySerivceImpl hljtDutySerivceImpl;
	@Autowired
	private HljtGradetimeServiceImpl hljtGradetimeServiceImpl;
	@Autowired
	private HljtSubjectServiceImpl hljtSubjectServiceImpl;
	@Autowired
	HljtOtherInterfacesService hljtOtherInterfacesService;
	
	
	/**
	 * 班主任详细信息接口
	 * @param classid
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping("/teacher")
	@ResponseBody

	public JsonInterface selectTeacher(Integer classid) throws Exception {
	//	String newIp= "http://"+this.getIp()+":8080";
		
		String newIp= WhetherNotToUpdate.getIp();
		
		JsonInterface jsonInterface=new JsonInterface();
		if(classid !=null) {
			Teacher Teacher=new Teacher();
			HljtTeacherclass  teacherclass=hljtTeacherclassServiceImpl.findTeacherInformation(classid,0);
			if(teacherclass !=null) {
				HljtTeacher hljtteacher =hljtTeacherServiceImpl.findTeacher(teacherclass.getTeacherid());
				Teacher.setTeacherImage(newIp+hljtteacher.getImages());
				Teacher.setTeacherName(hljtteacher.getName());
				Teacher.setTeacherSubject(hljtteacher.getSubject());
				Teacher.setTeacherIntroduction(hljtteacher.getIntroduction());
				Teacher.setTeacherLeaving(hljtteacher.getLeaving());
				
				JSONObject json = JSONObject.fromObject(Teacher);
				jsonInterface.setData(json.toString());
				jsonInterface.setErrCode(0);
				jsonInterface.setErrMsg("请求成功");
			}else {
				jsonInterface.setErrCode(1);
				jsonInterface.setErrMsg("无数据，请添加数据！");
			}
		}else {
			jsonInterface.setErrCode(5);
			jsonInterface.setErrMsg("请求失败");
		}
		return jsonInterface;
	}
	/**
	 * 本班级所有老师接口
	 * @param classid
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping("/teachers")
	@ResponseBody
	public JsonInterface selectTeachers(Integer classid) throws Exception {
		
		String newIp= WhetherNotToUpdate.getIp();
		
		JsonInterface jsonInterface=new JsonInterface();
		
		if(classid !=null) {
			List<HljtTeacherclass>  Teacherclass=hljtTeacherclassServiceImpl.findClassTeacher(classid);
			List<Teacher> listTeacher=new ArrayList<>();
			if(Teacherclass !=null) {
				for(int i=0;i<Teacherclass.size();i++) {
					Teacher Teacher=new Teacher();
					HljtTeacher teacher =hljtTeacherServiceImpl.findTeacher(Teacherclass.get(i).getTeacherid());
					System.out.println(Teacherclass.get(i).getTeacherid());
					Teacher.setTeacherImage(newIp+teacher.getImages());
					Teacher.setTeacherName(teacher.getName());
					Teacher.setTeacherSubject(teacher.getSubject());
					Teacher.setTeacherLeaving(teacher.getLeaving());
					Teacher.setTeacherIntroduction(teacher.getIntroduction());
					listTeacher.add(Teacher);
				}
				JSONArray array=JSONArray.fromObject(listTeacher);
				jsonInterface.setData(array.toString());
				jsonInterface.setErrCode(0);
				jsonInterface.setErrMsg("请求成功");
				
				//jsonUtil.setSucceed(jsonUtil.setSucceedMsg("班级所有老师", listTeacher), "请求成功");
			}else {
				jsonInterface.setData(null);
				jsonInterface.setErrCode(1);
				jsonInterface.setErrMsg("数据有误");
			}
		}else {
			jsonInterface.setErrCode(3);
			jsonInterface.setErrMsg("请求失败");
		}
		return jsonInterface;
	}
	/**
	 * 班级之星接口
	 * @param classid
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping("/isexcellent")
	@ResponseBody
	public JsonInterface selectStudent(Integer classid) throws Exception {
		
		String newIp= WhetherNotToUpdate.getIp();
		
		JsonInterface jsonInterface=new JsonInterface();
		ClassExcellent ClassExcellent=new ClassExcellent();
		if(classid!=null) {
			HljtClass  Class=hljtClassService.findClass(classid);
			if(null!=Class) {
				String studentClass=Class.getGrade()+"("+Class.getClasses()+")";
				if(Class.getStudentid()!=null) {
				HljtStudent student =hljtStudentServiceImpl.findStudent(Class.getStudentid());
				ClassExcellent.setStudentImage(newIp+student.getStudentimage());
				ClassExcellent.setStudentName(student.getName());
				ClassExcellent.setStudentClass(studentClass);
				ClassExcellent.setStudentEvaluate(student.getTitles());
				
				JSONObject json = JSONObject.fromObject(ClassExcellent);
				jsonInterface.setData(json.toString());
				jsonInterface.setErrCode(0);
				jsonInterface.setErrMsg("请求成功");
			}else {
				jsonInterface.setErrCode(1);
				jsonInterface.setErrMsg("无数据，请添加数据！");
			}
			}else {
				jsonInterface.setErrCode(1);
				jsonInterface.setErrMsg("无数据，请添加数据！");
			}
				
		}else {
			jsonInterface.setErrCode(3);
			jsonInterface.setErrMsg("请求失败");
		}
		return jsonInterface;
	}
	
	/**
	 * 名人名言接口
	 * @param classid
	 * @return
	 * @throws UnknownHostException 
	 */
	@RequestMapping("/Wellknownsaying")
	@ResponseBody
	public JsonInterface Wellknownsaying(Integer classid) {
		JsonInterface jsonInterface=new JsonInterface();
		if(null !=classid) {
			List<HljtClassnotify> Classnotify =hljtClassnotifyServiceImpl.findNotityList(classid, "3");
			if(null !=Classnotify) {
				List<String> saying=new ArrayList<>();
				for(int i=0;i<Classnotify.size();i++) {
					saying.add(Classnotify.get(i).getContent());
				}
				JSONArray array=JSONArray.fromObject(saying);
				jsonInterface.setData(array.toString());
				jsonInterface.setErrCode(0);
				jsonInterface.setErrMsg("请求成功");
			}else {
				jsonInterface.setData(null);
				jsonInterface.setErrCode(1);
				jsonInterface.setErrMsg("无数据，请添加数据！");
			}
		}else {
			jsonInterface.setErrCode(3);
			jsonInterface.setErrMsg("请求失败");
		}
		
		return jsonInterface;
	}
	/**
	 * 班级荣誉
	 * @param classid
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping("/Honor")
	@ResponseBody
	public JsonInterface Honor(Integer classid) throws Exception {
		JsonInterface jsonInterface=new JsonInterface();
		String newIp= WhetherNotToUpdate.getIp();
		if(null !=classid) {
			List<Images> listworks=new ArrayList<>();
			List<HljtClassimage>  l=hljtClassimageServiceImpl.findListImage(classid, "3",null);
			if(null !=l&&l.size()>0) {
				for(int i=0;i<l.size();i++) {
					Images Images=new Images();
					Images.setTitle(l.get(i).getTitle());
					Images.setPictureUrl(newIp+l.get(i).getImagepath());
					Images.setContent(l.get(i).getContent());
					listworks.add(Images);
				}
				JSONArray array=JSONArray.fromObject(listworks);
				jsonInterface.setData(array.toString());
				jsonInterface.setErrCode(0);
				jsonInterface.setErrMsg("请求成功");
			}else {
				//jsonInterface.setData(null);
				jsonInterface.setErrCode(1);
				jsonInterface.setErrMsg("无数据，请添加数据！");
			}
		}else {
			jsonInterface.setErrCode(3);
			jsonInterface.setErrMsg("请求失败");
		}
		
		return jsonInterface;
	}
	
	/**
	 * 班级风采
	 * @param classid
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping("/Style")
	@ResponseBody
	public JsonInterface Style(Integer classid) throws Exception {
		JsonInterface jsonInterface=new JsonInterface();
		String newIp= WhetherNotToUpdate.getIp();
		if(null !=classid) {
			List<Images> listworks=new ArrayList<>();
			List<HljtClassimage>  l=hljtClassimageServiceImpl.findListImage(classid, "4",null);
			if(null !=l) {
				for(int i=0;i<l.size();i++) {
					Images Images=new Images();
					Images.setTitle(l.get(i).getTitle());
					Images.setPictureUrl(newIp+l.get(i).getImagepath());
					Images.setContent(l.get(i).getContent());
					listworks.add(Images);
				}
				JSONArray array=JSONArray.fromObject(listworks);
				jsonInterface.setData(array.toString());
				jsonInterface.setErrCode(0);
				jsonInterface.setErrMsg("请求成功");
			}else {
				jsonInterface.setData(null);
				jsonInterface.setErrCode(1);
				jsonInterface.setErrMsg("无数据，请添加数据！");
			}
		}else {
			jsonInterface.setErrCode(3);
			jsonInterface.setErrMsg("请求失败");
		}
		return jsonInterface;
	}
	
	/**
	 * 班级视频
	 * @param classid
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping("/video")
	@ResponseBody
	public JsonInterface video(Integer classid) throws Exception {
		JsonInterface jsonInterface=new JsonInterface();
		String newIp= WhetherNotToUpdate.getIp();
		if(null !=classid) {
			List<Images> listworks=new ArrayList<>();
			List<HljtClassimage>  l=hljtClassimageServiceImpl.findListImage(classid, "7",null);
			if(null !=l) {
				for(int i=0;i<l.size();i++) {
					Images Images=new Images();
					Images.setTitle(l.get(i).getTitle());
					Images.setPictureUrl(newIp+l.get(i).getImagepath());
					Images.setContent(l.get(i).getContent());
					listworks.add(Images);
				}
				JSONArray array=JSONArray.fromObject(listworks);
				jsonInterface.setData(array.toString());
				jsonInterface.setErrCode(0);
				jsonInterface.setErrMsg("请求成功");
			}else {
				jsonInterface.setData(null);
				jsonInterface.setErrCode(1);
				jsonInterface.setErrMsg("无数据，请添加数据！");
			}
		}else {
			jsonInterface.setErrCode(3);
			jsonInterface.setErrMsg("请求失败");
		}
		return jsonInterface;
	}
	
	/**
	 * 班级课程表
	 * @param classid
	 * @return
	 * @throws UnknownHostException
	 */
	@RequestMapping("/curriculum")
	@ResponseBody
	public JsonInterface curriculum(Integer classid){
		JsonInterface jsonInterface=new JsonInterface();
		if(null !=classid) {
			List<HljtClassschedulecard> hljtClassschedulecard =hljtClassschedulecardServiceImpl.findClassschedulecard(classid);
			
			if(null !=hljtClassschedulecard) {
				ClassCurriculum ClassCurriculum=new ClassCurriculum();
				List<String> listmondy=new ArrayList<>();
				List<String> listtuesday=new ArrayList<>();
				List<String> listwednesday=new ArrayList<>();
				List<String> listthursday=new ArrayList<>();
				List<String> listfriday=new ArrayList<>();
				List<String> listsaturday=new ArrayList<>();
				List<String> listsunday=new ArrayList<>();
				for(int i=0;i<hljtClassschedulecard.size();i++) {
					listmondy.add(hljtClassschedulecard.get(i).getMonday());
				}
				for(int i=0;i<hljtClassschedulecard.size();i++) {
					listtuesday.add(hljtClassschedulecard.get(i).getTuesday());
				}
				for(int i=0;i<hljtClassschedulecard.size();i++) {
					listwednesday.add(hljtClassschedulecard.get(i).getWednesday());
				}
				for(int i=0;i<hljtClassschedulecard.size();i++) {
					listthursday.add(hljtClassschedulecard.get(i).getThursday());
				}
				for(int i=0;i<hljtClassschedulecard.size();i++) {
					listfriday.add(hljtClassschedulecard.get(i).getFriday());
				}
				for(int i=0;i<hljtClassschedulecard.size();i++) {
					listsaturday.add(hljtClassschedulecard.get(i).getSaturday());
				}
				for(int i=0;i<hljtClassschedulecard.size();i++) {
					listsunday.add(hljtClassschedulecard.get(i).getSunday());
				}
				ClassCurriculum.setMonday(listmondy);
				ClassCurriculum.setTuesday((listtuesday));
				ClassCurriculum.setWednesday((listwednesday));
				ClassCurriculum.setThursday(listthursday);
				ClassCurriculum.setFriday((listfriday));
				ClassCurriculum.setSaturday(listsaturday);
				ClassCurriculum.setSunday(listsunday);
				JSONObject json=JSONObject.fromObject(ClassCurriculum);
				jsonInterface.setData(json.toString());
				jsonInterface.setErrCode(0);
				jsonInterface.setErrMsg("请求成功");
			}else {
				jsonInterface.setData(null);
				jsonInterface.setErrCode(1);
				jsonInterface.setErrMsg("无数据，请添加数据！");
			}
		}else {
			jsonInterface.setErrCode(3);
			jsonInterface.setErrMsg("请求失败");
		}
		return jsonInterface;
	}
	
	/**
	 * 德育评分
	 * @param classid
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping("/education")
	@ResponseBody
	public JsonInterface education(Integer classid) throws Exception{

		JsonInterface jsonInterface=new JsonInterface();
		String newIp= WhetherNotToUpdate.getIp();
		JSONObject js=new JSONObject();
			if(null !=classid) {
				List<HljtEducation> hljtEducation=hljtEducationSerivceImpl.findEducation(classid,null);
				List<MoralEducation> moralEducationlist=new ArrayList<>();
				double number =0.0;
				if(null !=hljtEducation) {
					for(int i=0;i<hljtEducation.size();i++) {
						MoralEducation moralEducation=new MoralEducation();
						moralEducation.setRemarks(hljtEducation.get(i).getRemarks());
						HljtDuty Duty=hljtDutySerivceImpl.findHljtDuty(hljtEducation.get(i).getDutyid());
						moralEducation.setImage(newIp+Duty.getDutyimage());
						moralEducation.setName(Duty.getDutyname());
						moralEducation.setNumber(hljtEducation.get(i).getFraction()+"");
						double aa=hljtEducation.get(i).getFraction();
						number= number+aa;
						moralEducationlist.add(moralEducation);
					}
					JSONArray array=JSONArray.fromObject(moralEducationlist);
					js.put("total", number);
					js.put("moralEducationlist", array);
					jsonInterface.setData(js.toString());
					jsonInterface.setErrCode(0);
					jsonInterface.setErrMsg("请求成功");
				}else {
					jsonInterface.setData(null);
					jsonInterface.setErrCode(1);
					jsonInterface.setErrMsg("无数据，请添加数据！");
				}
			}else {
				jsonInterface.setErrCode(3);
				jsonInterface.setErrMsg("请求失败");
			}
		return jsonInterface;
	}
//==========================================================================WEB接口============================================================================================================
	/**
	 * web端班级风采分页查询接口
	 * @param classid
	 * @param type
	 * @param rep
	 * @param pageSize
	 * @param pageIndex
	 * @param title
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping("/selectclass")
	@ResponseBody
	public Message selectclass(Integer classid,String type,String title,Integer pageSize,Integer  pageIndex,HttpServletResponse rep) throws Exception {
		RepUtil.repPake(rep);
		String newIp= WhetherNotToUpdate.getIp();
		Message Message=new Message();
		Map<String, Object> data =new HashMap<>();
		
		if(null !=type&& null!=classid) {
			if(classid>-1) {
				List<ClassImage> hljtClassImages=new ArrayList<>();
				List<HljtClass> Class=hljtClassService.pageFindClassList(classid,null,null,null);
				if(null !=title) {
					pageIndex=(pageIndex-1)*pageSize;
					List<HljtClassimage> Classimages=hljtClassimageServiceImpl.findListImage(classid, type,null);
					List<HljtClassimage> Classimage=hljtClassimageServiceImpl.findListImagelikepage(title, pageSize, pageIndex, classid, type);
					for(int i=0;i<Classimage.size();i++) {
						ClassImage HljtClassImage=new ClassImage();
						HljtClassImage.setId(Classimage.get(i).getId());
						HljtClassImage.setClassid(Classimage.get(i).getClassid());
						HljtClassImage.setImagepath(newIp+Classimage.get(i).getImagepath());
						HljtClassImage.setTitle(Classimage.get(i).getTitle());
						HljtClassImage.setContent(Classimage.get(i).getContent());
						
						HljtClass HljtClass=hljtClassService.findClass(Classimage.get(i).getClassid());
						HljtClassImage.setClasses(HljtClass.getGrade());
						HljtClassImage.setLevel(HljtClass.getClasses());
						
						hljtClassImages.add(HljtClassImage);
					}
					
					data.put("data", hljtClassImages);
					if( null !=Classimages&& Classimages.size()>0) {
						data.put("Total", Classimages.size());
					}else {
						data.put("Total", null);
					}
					data.put("class", Class);
					data.put("success", "SUCCESS");
				}else {
					pageIndex=(pageIndex-1)*pageSize;
					List<HljtClassimage> Classimages=hljtClassimageServiceImpl.findListImage(classid, type,null);
					List<HljtClassimage> Classimage=hljtClassimageServiceImpl.findListImagelikepage(null, pageSize, pageIndex, classid, type);
					for(int i=0;i<Classimage.size();i++) {
						ClassImage HljtClassImage=new ClassImage();
						HljtClassImage.setId(Classimage.get(i).getId());
						HljtClassImage.setClassid(Classimage.get(i).getClassid());
						HljtClassImage.setImagepath(newIp+Classimage.get(i).getImagepath());
						HljtClassImage.setTitle(Classimage.get(i).getTitle());
						HljtClassImage.setContent(Classimage.get(i).getContent());
						
						HljtClass HljtClass=hljtClassService.findClass(Classimage.get(i).getClassid());
						HljtClassImage.setClasses(HljtClass.getGrade());
						HljtClassImage.setLevel(HljtClass.getClasses());
						
						hljtClassImages.add(HljtClassImage);
					}
					
					data.put("data", hljtClassImages);
					if( null !=Classimages&& Classimages.size()>0) {
						data.put("Total", Classimages.size());
					}else {
						data.put("Total", null);
					}
					data.put("class", Class);
					data.put("success", "SUCCESS");
				}
			}else {
				List<ClassImage> hljtClassImages=new ArrayList<>();
				classid=null;
				List<HljtClass> Class=hljtClassService.pageFindClassList(classid,null,null,null);
				if(null !=title) {
					pageIndex=(pageIndex-1)*pageSize;
					List<HljtClassimage> Classimages=hljtClassimageServiceImpl.findListImage(classid, type,title);
					List<HljtClassimage> Classimage=hljtClassimageServiceImpl.findListImagelikepage(title, pageSize, pageIndex, classid, type);
					for(int i=0;i<Classimage.size();i++) {
						ClassImage HljtClassImage=new ClassImage();
						HljtClassImage.setId(Classimage.get(i).getId());
						HljtClassImage.setClassid(Classimage.get(i).getClassid());
						HljtClassImage.setImagepath(newIp+Classimage.get(i).getImagepath());
						HljtClassImage.setTitle(Classimage.get(i).getTitle());
						HljtClassImage.setContent(Classimage.get(i).getContent());
						
						HljtClass HljtClass=hljtClassService.findClass(Classimage.get(i).getClassid());
						HljtClassImage.setClasses(HljtClass.getGrade());
						HljtClassImage.setLevel(HljtClass.getClasses());
						
						hljtClassImages.add(HljtClassImage);
					}
					
					data.put("data", hljtClassImages);
					if( null !=Classimages&& Classimages.size()>0) {
						data.put("Total", Classimages.size());
					}else {
						data.put("Total", null);
					}
					data.put("class", Class);
					data.put("success", "SUCCESS");
				}else {
					pageIndex=(pageIndex-1)*pageSize;
					List<HljtClassimage> Classimages=hljtClassimageServiceImpl.findListImage(classid, type,null);
					List<HljtClassimage> Classimage=hljtClassimageServiceImpl.findListImagelikepage(null, pageSize, pageIndex, classid, type);
					
					for(int i=0;i<Classimage.size();i++) {
						ClassImage HljtClassImage=new ClassImage();
						HljtClassImage.setId(Classimage.get(i).getId());
						HljtClassImage.setClassid(Classimage.get(i).getClassid());
						HljtClassImage.setImagepath(newIp+Classimage.get(i).getImagepath());
						HljtClassImage.setTitle(Classimage.get(i).getTitle());
						HljtClassImage.setContent(Classimage.get(i).getContent());
						HljtClass HljtClass=hljtClassService.findClass(Classimage.get(i).getClassid());
						HljtClassImage.setClasses(HljtClass.getGrade());
						HljtClassImage.setLevel(HljtClass.getClasses());
						hljtClassImages.add(HljtClassImage);
					}
					data.put("data", hljtClassImages);
					if( null !=Classimages&& Classimages.size()>0) {
						data.put("Total", Classimages.size());
					}else {
						data.put("Total", null);
					}
					data.put("class", Class);
					data.put("success", "SUCCESS");
				}
			}
		}else {
			data.put("success", "SUCCESS");
		}
		Message.setData(data);
		return Message;
	}
	
	/**
	 * web班级风采删除接口
	 * @param id
	 * @return
	 */
	@RequestMapping("/deleteclassimage")
	@ResponseBody
	public Message deleteclassimage(Integer classid , Integer id,HttpServletResponse rep) {
		Message Message=new Message();
		RepUtil.repPake(rep);
		Map<String, Object> data =new HashMap<>();
		if(null !=id) {
			
			hljtClassimageServiceImpl.deleteclassImage(id);
			hljtOtherInterfacesService.modifyByCalssId(classid);
			data.put("success", "删除成功");
		}else {
			data.put("error", "删除错误");
		}
		Message.setData(data);
		return Message;
	}
	
	/**
	 * web班级风采添加接口
	 * @return
	 * @throws IOException 
	 * @throws IllegalStateException 
	 */
	@RequestMapping("/addclassimage")
	@ResponseBody
	public Message addclassimage(Integer classid,String title,String content,String type,MultipartFile imgFile,HttpServletResponse rep) throws Exception {
		Message Message=new Message();
		RepUtil.repPake(rep);
		Map<String, Object> data =new HashMap<>();
		if(null!=classid && null !=title && null!=content && null !=imgFile) {
		if(classid>-1) {
			//生成新的图片名字
			String name = UUID.randomUUID().toString().replaceAll("-", "");
			//图片后缀名
			String ext = FilenameUtils.getExtension(imgFile.getOriginalFilename());
			//保存路径D:\java\apache-tomcat-8.0.48\webapps\image\class
			imgFile.transferTo(new File(WhetherNotToUpdate.getSaveDisk() + name + "." + ext));
			
			//新的图片名字
			String image=name+"."+ext;
			HljtClassimage classimage=new HljtClassimage();
			classimage.setImagepath(WhetherNotToUpdate.getReadDisk()+image);
			classimage.setClassid(classid);
			classimage.setTitle(title);
			classimage.setContent(content);
			classimage.setType(type);
			
			hljtClassimageServiceImpl.addcassImage(classimage);
			
			hljtOtherInterfacesService.modifyByCalssId(classid);
			data.put("success", "SUCCESS");
		}else {
			//生成新的图片名字
			String name = UUID.randomUUID().toString().replaceAll("-", "");
			//图片后缀名
			String ext = FilenameUtils.getExtension(imgFile.getOriginalFilename());
			//保存路径D:\java\apache-tomcat-8.0.48\webapps\image\class
			imgFile.transferTo(new File(WhetherNotToUpdate.getSaveDisk() + name + "." + ext));
			//新的图片名字
			String image=name+"."+ext;
			HljtClassimage classimage=new HljtClassimage();
			classimage.setImagepath(WhetherNotToUpdate.getReadDisk()+image);
			classimage.setClassid(classid);
			classimage.setTitle(title);
			classimage.setContent(content);
			classimage.setType(type);
			
			hljtClassimageServiceImpl.addcassImage(classimage);
			
			hljtOtherInterfacesService.modifyByCalssId(classid);
			data.put("success", "SUCCESS");
		}
		}else {	
		data.put("error", false);
		}
		Message.setData(data);
		return Message;
	}
	
	
	/**
	 * web班级风采修改接口
	 * @return
	 * @throws IOException 
	 * @throws IllegalStateException 
	 */
	@RequestMapping("/updateclassimage")
	@ResponseBody
	public Message updateclassimage(Integer classid , Integer id,String content,String title,MultipartFile imgFile,HttpServletResponse rep) throws Exception{
		Message Message=new Message();
		RepUtil.repPake(rep);
		Map<String, Object> data =new HashMap<>();
		if(null !=id && null !=content && null!=title) {
			HljtClassimage classimage=hljtClassimageServiceImpl.findImage(id);
			HljtClassimage hljtClassimage=new HljtClassimage();
			hljtClassimage.setId(id);
			hljtClassimage.setTitle(title);
			hljtClassimage.setContent(content);
			if(imgFile.getSize()>0) {
				//生成新的图片名字
				String name = UUID.randomUUID().toString().replaceAll("-", "");
				//图片后缀名
				String ext = FilenameUtils.getExtension(imgFile.getOriginalFilename());
				//保存路径
				imgFile.transferTo(new File(WhetherNotToUpdate.getSaveDisk() + name + "." + ext));
				//新的图片名字
				String image=name+"."+ext;
				hljtClassimage.setImagepath(WhetherNotToUpdate.getReadDisk()+image);
			}else {
				hljtClassimage.setImagepath(classimage.getImagepath());
			}
			
			
			hljtClassimageServiceImpl.updateImage(hljtClassimage);
			hljtOtherInterfacesService.modifyByCalssId(classid);

			data.put("success", true);

		}else {
			data.put("success", false);
		}
		Message.setData(data);
		return Message;
	}
	
	/**
	 * web班级视频模糊查询
	 * @return
	 * @throws Exception 
	 * @throws IOException 
	 * @throws IllegalStateException 
	 */
	@RequestMapping("/selectclassvideo")
	@ResponseBody
	public Message selectclassvideo(String title,Integer classid,String type,Integer pageSize,Integer  pageIndex,HttpServletResponse rep) throws Exception{
		RepUtil.repPake(rep);
		Message Message=new Message();
		Map<String, Object> data =new HashMap<>();
		String newIp= WhetherNotToUpdate.getIp();
		if(null !=classid) {
			if(classid>-1) {
				List<HljtClass> Class=hljtClassService.pageFindClassList(classid,null,null,null);
				List<ClassImage> hljtClassImages=new ArrayList<>();
				if(null !=title) {
					pageIndex=(pageIndex-1)*pageSize;
					List<HljtClassimage> Classimages=hljtClassimageServiceImpl.findListImage(classid, type,title);
					List<HljtClassimage> Classimage=hljtClassimageServiceImpl.findListImagelikepage(title, pageSize, pageIndex, classid, type);
					for(int i=0;i<Classimage.size();i++) {
						ClassImage HljtClassImage=new ClassImage();
						HljtClassImage.setId(Classimage.get(i).getId());
						HljtClassImage.setClassid(Classimage.get(i).getClassid());
						if(Classimage.get(i).getImagepath().substring(0, 4).equals("http")) {
							HljtClassImage.setImagepath(Classimage.get(i).getImagepath());
						}else {
							HljtClassImage.setImagepath(newIp+Classimage.get(i).getImagepath());
						}
						HljtClassImage.setTitle(Classimage.get(i).getTitle());
						HljtClassImage.setContent(Classimage.get(i).getContent());
						
						HljtClass HljtClass=hljtClassService.findClass(Classimage.get(i).getClassid());
						HljtClassImage.setClasses(HljtClass.getGrade());
						HljtClassImage.setLevel(HljtClass.getClasses());
						
						hljtClassImages.add(HljtClassImage);
					}
					
					data.put("data", hljtClassImages);
					data.put("class", Class);
					if(null!=Classimages &&Classimages.size()>0) {
						data.put("Total", Classimages.size());
					}else {
						data.put("Total", null);
					}
					data.put("success",true);
					}else {
						pageIndex=(pageIndex-1)*pageSize;
						List<HljtClassimage> Classimages=hljtClassimageServiceImpl.findListImage(classid, type,null);
						List<HljtClassimage> Classimage=hljtClassimageServiceImpl.findListImagelikepage(null, pageSize, pageIndex, classid, type);
						for(int i=0;i<Classimage.size();i++) {
							ClassImage HljtClassImage=new ClassImage();
							HljtClassImage.setId(Classimage.get(i).getId());
							HljtClassImage.setClassid(Classimage.get(i).getClassid());
							if(Classimage.get(i).getImagepath().substring(0, 4).equals("http")) {
								HljtClassImage.setImagepath(Classimage.get(i).getImagepath());
							}else {
								HljtClassImage.setImagepath(newIp+Classimage.get(i).getImagepath());
							}
							HljtClassImage.setTitle(Classimage.get(i).getTitle());
							HljtClassImage.setContent(Classimage.get(i).getContent());
							
							HljtClass HljtClass=hljtClassService.findClass(Classimage.get(i).getClassid());
							HljtClassImage.setClasses(HljtClass.getGrade());
							HljtClassImage.setLevel(HljtClass.getClasses());
							
							hljtClassImages.add(HljtClassImage);
						}
						
						data.put("data", hljtClassImages);
						data.put("class", Class);
						if(null!=Classimages &&Classimages.size()>0) {
							data.put("Total", Classimages.size());
						}else {
							data.put("Total", null);
						}
						data.put("success", true);
					}
			}else {
				List<ClassImage> hljtClassImages=new ArrayList<>();
				classid=null;
				List<HljtClass> Class=hljtClassService.pageFindClassList(classid,null,null,null);
				if(null !=title) {
					pageIndex=(pageIndex-1)*pageSize;
					List<HljtClassimage> Classimages=hljtClassimageServiceImpl.findListImage(classid, type,title);
					List<HljtClassimage> Classimage=hljtClassimageServiceImpl.findListImagelikepage(title, pageSize, pageIndex, classid, type);
					for(int i=0;i<Classimage.size();i++) {
						ClassImage HljtClassImage=new ClassImage();
						HljtClassImage.setId(Classimage.get(i).getId());
						HljtClassImage.setClassid(Classimage.get(i).getClassid());
						if(Classimage.get(i).getImagepath().substring(0, 4).equals("http")) {
							HljtClassImage.setImagepath(Classimage.get(i).getImagepath());
						}else {
							HljtClassImage.setImagepath(newIp+Classimage.get(i).getImagepath());
						}
						HljtClassImage.setTitle(Classimage.get(i).getTitle());
						HljtClassImage.setContent(Classimage.get(i).getContent());
						
						HljtClass HljtClass=hljtClassService.findClass(Classimage.get(i).getClassid());
						HljtClassImage.setClasses(HljtClass.getGrade());
						HljtClassImage.setLevel(HljtClass.getClasses());
						
						hljtClassImages.add(HljtClassImage);
					}
					
					data.put("data", hljtClassImages);
					if(null!=Classimages &&Classimages.size()>0) {
						data.put("Total", Classimages.size());
					}else {
						data.put("Total", null);
					}
					data.put("class", Class);
					data.put("success", true);
				}else {
					pageIndex=(pageIndex-1)*pageSize;
					List<HljtClassimage> Classimages=hljtClassimageServiceImpl.findListImage(classid, type,null);
					List<HljtClassimage> Classimage=hljtClassimageServiceImpl.findListImagelikepage(title, pageSize, pageIndex, classid, type);
					for(int i=0;i<Classimage.size();i++) {
						ClassImage HljtClassImage=new ClassImage();
						HljtClassImage.setId(Classimage.get(i).getId());
						HljtClassImage.setClassid(Classimage.get(i).getClassid());
						if(Classimage.get(i).getImagepath().substring(0, 4).equals("http")) {
							HljtClassImage.setImagepath(Classimage.get(i).getImagepath());
						}else {
							HljtClassImage.setImagepath(newIp+Classimage.get(i).getImagepath());
						}
						HljtClassImage.setTitle(Classimage.get(i).getTitle());
						HljtClassImage.setContent(Classimage.get(i).getContent());
						HljtClass HljtClass=hljtClassService.findClass(Classimage.get(i).getClassid());
						HljtClassImage.setClasses(HljtClass.getGrade());
						HljtClassImage.setLevel(HljtClass.getClasses());
						hljtClassImages.add(HljtClassImage);
					}
					data.put("data", hljtClassImages);
					if(null!=Classimages &&Classimages.size()>0) {
						data.put("Total", Classimages.size());
					}else {
						data.put("Total", null);
					}
					data.put("class", Class);
					data.put("success", true);
				}
			}
		}else {
			data.put("success", false);
		}
		Message.setData(data);
		return Message;
		}
	/**
	 * 视频添加接口(手动输入)
	 * @param imagename
	 * @param classid
	 * @param imgFile
	 * @param type
	 * @param rep
	 * @return
	 * @throws IOException 
	 * @throws IllegalStateException 
	 */
	@RequestMapping("/addclassvideo")
	@ResponseBody
	public Message addclassvideo(Integer classid,MultipartFile imgFile,String type,String content,HttpServletResponse rep) throws Exception{
		RepUtil.repPake(rep);
		Message Message=new Message();
		Map<String, Object> data =new HashMap<>();
	
		if(null !=classid) {
			
			//获取传过来的文件名
		//	String name=FilenameUtils.getBaseName(imgFile.getOriginalFilename());
			//生成新的图片名字
			String name = UUID.randomUUID().toString().replaceAll("-", "");
			//图片后缀名
			String ext = FilenameUtils.getExtension(imgFile.getOriginalFilename());
			Date date=new Date();
			//保存路径D:\java\apache-tomcat-8.0.48\webapps\image\class
			imgFile.transferTo(new File(WhetherNotToUpdate.getSaveDisk() + name + "." + ext));
			HljtClassimage classimage=new HljtClassimage();
			String image=name+"."+ext;
			classimage.setClassid(classid);
			classimage.setImagepath(WhetherNotToUpdate.getReadDisk()+image);
			classimage.setTitle(name);
			classimage.setContent(content);
			classimage.setType(type);
			
			hljtClassimageServiceImpl.addcassImage(classimage);
			hljtOtherInterfacesService.modifyByCalssId(classid);
			data.put("success", true);
		}else {
			data.put("success", false);
		}
		
		Message.setData(data);
		return Message;
	}
	/**
	 * 视频添加接口(链接)
	 * @param classid
	 * @param type
	 * @param imagepath
	 * @param content
	 * @param title
	 * @param rep
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/addclassvideopath")
	@ResponseBody
	public Message addclassvideopath(Integer classid,String type,String imagepath,String content,String title,HttpServletResponse rep) throws Exception{
		RepUtil.repPake(rep);
		Message Message=new Message();
		Map<String, Object> data =new HashMap<>();
		if(null !=classid && null !=imagepath) {
			HljtClassimage classimage=new HljtClassimage();
			classimage.setClassid(classid);
			classimage.setType(type);
			classimage.setImagepath(imagepath);
			classimage.setContent(content);
			classimage.setTitle(title);
			
			hljtClassimageServiceImpl.addcassImage(classimage);
			hljtOtherInterfacesService.modifyByCalssId(classid);
			data.put("success", true);
		}else {
			
			data.put("success", false);
		}
		Message.setData(data);
		return Message;
	}
	
	/**
	 * 视频修改接口
	 * @param id
	 * @param title
	 * @param rep
	 * @return
	 */
	@RequestMapping("/updateclassvideo")
	@ResponseBody
	public Message updateclassvideo(Integer classid, Integer id,String title,HttpServletResponse rep){
		RepUtil.repPake(rep);
		Message Message=new Message();
		Map<String, Object> data =new HashMap<>();
		if(null !=id) {
			HljtClassimage Classimg=hljtClassimageServiceImpl.findImage(id);
			
			HljtClassimage hljtClassimage=new HljtClassimage();
			hljtClassimage.setId(id);
			hljtClassimage.setTitle(title);
			hljtClassimage.setImagepath(Classimg.getImagepath());
			hljtClassimage.setContent(Classimg.getContent());
			
			
			hljtClassimageServiceImpl.updateImage(hljtClassimage);
			hljtOtherInterfacesService.modifyByCalssId(classid);
			data.put("success", true);
		}else {
			
			data.put("success", false);
		}
		Message.setData(data);
		return Message;
	}
	/**
	 * 视频删除接口
	 * @param id
	 * @param rep
	 * @return
	 */
	@RequestMapping("/deleteclassvideo")
	@ResponseBody
	public Message deleteclassvideo(Integer classid, Integer id,HttpServletResponse rep){
		RepUtil.repPake(rep);
		Message Message=new Message();
		Map<String, Object> data =new HashMap<>();
		if(null !=id) {
			hljtClassimageServiceImpl.deleteclassImage(id);
			hljtOtherInterfacesService.modifyByCalssId(classid);
			data.put("success", true);
		}else {
			data.put("success", false);
		}
		Message.setData(data);
		return Message;
	}
	
	/**
	 * web班级名人名言查询
	 * @return
	 * @throws IOException 
	 * @throws IllegalStateException 
	 */
	@RequestMapping("/selectclasswisdoms")
	@ResponseBody
	public Message selectclasswisdom(String title,Integer classid,String type,Integer pageSize,Integer  pageIndex,HttpServletResponse rep){
		RepUtil.repPake(rep);
		Message Message=new Message();
		Map<String, Object> data =new HashMap<>();
		if(null != type && null!=classid) {
			if(classid>-1) {
				List<ClassNotity> ClassNotity=new ArrayList<>();
				HljtClass HljtClass=hljtClassService.findClass(classid);
				if(null !=title) {
					pageIndex=(pageIndex-1)*pageSize;
					List<HljtClassnotify> Classnotify =hljtClassnotifyServiceImpl.findListImagelikepage(title, pageSize, pageIndex, classid, type);
					List<HljtClassnotify> Classnotifys =hljtClassnotifyServiceImpl.findclassimage(title, classid, type);
					List<HljtClass> Class=hljtClassService.pageFindClassList(classid,null,null,null);
					hljtClassServiceIpml.findClass(classid);
					for(int i=0;i<Classnotify.size();i++) {
						ClassNotity classNotity=new ClassNotity();
						classNotity.setId(Classnotify.get(i).getId());
						classNotity.setClassid(Classnotify.get(i).getClassid());
						classNotity.setTitle(Classnotify.get(i).getTitle());
						classNotity.setContent(Classnotify.get(i).getContent());
						
						classNotity.setClasses(HljtClass.getGrade());
						classNotity.setLevel(HljtClass.getClasses());
						ClassNotity.add(classNotity);
					}
					data.put("data", ClassNotity);
					data.put("class", Class);
					data.put("Total", Classnotifys.size());
					data.put("success", true);
				}else {
					pageIndex=(pageIndex-1)*pageSize;
					List<HljtClassnotify> Classnotify =hljtClassnotifyServiceImpl.findListImagelikepage(null, pageSize, pageIndex, classid, type);
					List<HljtClassnotify> Classnotifys =hljtClassnotifyServiceImpl.findNotityList(classid, type);
					List<HljtClass> Class=hljtClassService.pageFindClassList(classid,null,null,null);
					
					for(int i=0;i<Classnotify.size();i++) {
						ClassNotity classNotity=new ClassNotity();
						classNotity.setId(Classnotify.get(i).getId());
						classNotity.setClassid(Classnotify.get(i).getClassid());
						classNotity.setTitle(Classnotify.get(i).getTitle());
						classNotity.setContent(Classnotify.get(i).getContent());
						classNotity.setClasses(HljtClass.getGrade());
						classNotity.setLevel(HljtClass.getClasses());
						
						ClassNotity.add(classNotity);
					}
					
					data.put("data", ClassNotity);
					
					data.put("class", Class);
					data.put("Total", Classnotifys.size());
					data.put("success", true);
				}
			}else {
				classid=null;
				List<ClassNotity> ClassNotity=new ArrayList<>();
				if(null !=title) {
					pageIndex=(pageIndex-1)*pageSize;
					List<HljtClassnotify> Classnotifys =hljtClassnotifyServiceImpl.findclassimage(title, classid, type);
					List<HljtClassnotify> Classnotify =hljtClassnotifyServiceImpl.findListImagelikepage(title, pageSize, pageIndex, classid, type);
					List<HljtClass> Class=hljtClassService.pageFindClassList(classid,null,null,null);
					for(int i=0;i<Classnotify.size();i++) {
						ClassNotity classNotity=new ClassNotity();
						classNotity.setId(Classnotify.get(i).getId());
						classNotity.setClassid(Classnotify.get(i).getClassid());
						classNotity.setTitle(Classnotify.get(i).getTitle());
						classNotity.setContent(Classnotify.get(i).getContent());
						HljtClass HljtClass=hljtClassService.findClass(Classnotify.get(i).getClassid());
						classNotity.setClasses(HljtClass.getGrade());
						classNotity.setLevel(HljtClass.getClasses());
						
						ClassNotity.add(classNotity);
					}
					data.put("data", ClassNotity);
					data.put("class", Class);
					data.put("Total", Classnotifys.size());
					data.put("success", true);
				}else {
					
					pageIndex=(pageIndex-1)*pageSize;
					List<HljtClass> Class=hljtClassService.pageFindClassList(classid,null,null,null);
					List<HljtClassnotify> Classnotifys =hljtClassnotifyServiceImpl.findNotityList(classid, type);
					List<HljtClassnotify> Classnotifyss =hljtClassnotifyServiceImpl.findNotityLists(classid, type, pageSize, pageIndex);
					for(int i=0;i<Classnotifyss.size();i++) {
						ClassNotity classNotity=new ClassNotity();
						classNotity.setId(Classnotifyss.get(i).getId());
						classNotity.setClassid(Classnotifyss.get(i).getClassid());
						classNotity.setTitle(Classnotifyss.get(i).getTitle());
						classNotity.setContent(Classnotifyss.get(i).getContent());
						HljtClass HljtClass=hljtClassService.findClass(Classnotifyss.get(i).getClassid());
						if(null!=HljtClass) {
							classNotity.setClasses(HljtClass.getGrade());
							classNotity.setLevel(HljtClass.getClasses());
						}else {
							classNotity.setClasses(null);
							classNotity.setLevel(null);
						}
						
						
						ClassNotity.add(classNotity);
					}
					
					data.put("data", ClassNotity);
					data.put("Total", Classnotifys.size());
					data.put("class", Class);
					data.put("success", true);
				}
				
			}
		}else {
			data.put("success", false);
		}
		Message.setData(data);
		return Message;
	}
	/**
	 * web班级名人名言删除
	 * @return
	 * @throws IOException 
	 * @throws IllegalStateException 
	 */
	@RequestMapping("/deleteclasswisdom")
	@ResponseBody
	public Message deleteclasswisdom(Integer classid ,Integer id,HttpServletResponse rep){
		RepUtil.repPake(rep);
		Message Message=new Message();
		Map<String, Object> data =new HashMap<>();
		if(null !=id) {
			hljtClassnotifyServiceImpl.deletewisdom(id);
			hljtOtherInterfacesService.modifyByCalssId(classid);
			data.put("success", true);
		}else {
			data.put("success", false);
		}
		Message.setData(data);
		return Message;
		}
	/**
	 * 添加名人名言
	 * @param classid
	 * @param content
	 * @param type
	 * @param rep
	 * @return
	 */
	@RequestMapping("/addclasswisdom")
	@ResponseBody
	public Message addclasswisdom(Integer classid,String content,String title,String type,HttpServletResponse rep){
		RepUtil.repPake(rep);
		Message Message=new Message();
		Map<String, Object> data =new HashMap<>();
		if(null != classid && null != content && null !=type) {
			HljtClassnotify Classnotify=new HljtClassnotify();
			Classnotify.setClassid(classid);
			Classnotify.setContent(content);
			Classnotify.setType(type);
			Classnotify.setTitle(title);
			Date createtime=new Date();
			Classnotify.setCreatetime(createtime);
			hljtClassnotifyServiceImpl.addwisdom(Classnotify);
			hljtOtherInterfacesService.modifyByCalssId(classid);
			data.put("success", true);
		}else {
			data.put("success", false);
		}
		Message.setData(data);
		return Message;
	}
	
	/**
	 * 名人名言修改接口
	 * @param id
	 * @param content
	 * @param rep
	 * @return
	 */
	@RequestMapping("/updateclasswisdom")
	@ResponseBody
	public Message updateclasswisdom(Integer classid ,Integer id,String title,String content,HttpServletResponse rep){
		RepUtil.repPake(rep);
		Message Message=new Message();
		Map<String, Object> data =new HashMap<>();
		
		System.out.println(id);
		System.out.println(title);
		System.out.println(content);
		if(null !=id && null !=content && null !=title) {
			HljtClassnotify Classnotify=new HljtClassnotify();
			Classnotify.setId(id);
			Classnotify.setContent(content);
			Classnotify.setTitle(title);
			Date createtime=new Date();
			Classnotify.setCreatetime(createtime);
			hljtClassnotifyServiceImpl.updatewisdom(Classnotify);
			hljtOtherInterfacesService.modifyByCalssId(classid);
			data.put("success", true);
		}else {
			data.put("success", false);
		}
		Message.setData(data);
		return Message;
	}
	/**
	 * 班级之星查询接口
	 * @param rep
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping("/selectclassstudentimage")
	@ResponseBody
	public Message selectClassStudentImage(String name,Integer classid,Integer pageSize,Integer  pageIndex,HttpServletResponse rep) throws Exception{
		RepUtil.repPake(rep);
		Message Message=new Message();
		String newIp= WhetherNotToUpdate.getIp();
		Map<String, Object> data =new HashMap<>();
		if (null !=classid) {
			if (classid>-1) {
				if(null !=name && name.length()>0 ) {
					List<ClassStudentImage> ListClassStudentImage=new ArrayList<>();
					pageIndex=(pageIndex-1)*pageSize;
					List<HljtClass> Classes=hljtClassService.pageFindClassList(classid, null, null,"1");
					List<HljtStudent> Students=hljtStudentServiceImpl.findStudentName(name, null, null);
					List<HljtStudent> Student=hljtStudentServiceImpl.findStudentName(name, pageSize, pageIndex);
					if(Student!=null&&Student.size()>0) {
						for(int i=0;i<Student.size();i++) {
							ClassStudentImage ClassStudentImage=new ClassStudentImage();
							int Cid=Student.get(i).getClassid();
							HljtClass Class=hljtClassService.findClass(Cid);
							ClassStudentImage.setId(Student.get(i).getId());
							ClassStudentImage.setClassid(Student.get(i).getClassid());
							ClassStudentImage.setClasses(Class.getGrade());
							ClassStudentImage.setLevel(Class.getClasses());
							ClassStudentImage.setContent(Student.get(i).getEvaluate());
							ClassStudentImage.setStudentName(Student.get(i).getName());
							ClassStudentImage.setImagePath(newIp+Student.get(i).getStudentimage());
							ClassStudentImage.setTitle(Student.get(i).getTitles());
							ListClassStudentImage.add(ClassStudentImage);
						}
						data.put("data", ListClassStudentImage);
						data.put("Total", Students.size());
						data.put("class", Classes);
						data.put("success", true);
					}else {
						data.put("data", ListClassStudentImage);
						if(null!=Students&&Students.size()>0) {
							data.put("Total", Students.size());
						}else {
							data.put("Total", null);
						}
						data.put("class", Classes);
						data.put("success", false);
					}
					
				}else {
					List<ClassStudentImage> ListClassStudentImage=new ArrayList<>();
					classid=null;
					List<HljtClass> Class=hljtClassService.pageFindClassList(classid, null, null,"1");
					if(Class !=null && Class.size()>0) {
						for(int i=0;i<Class.size();i++) {
							ClassStudentImage ClassStudentImage=new ClassStudentImage();
							int id=Class.get(i).getStudentid();
							
							HljtStudent Student=hljtStudentServiceImpl.findStudent(id);
							ClassStudentImage.setId(Student.getId());
							ClassStudentImage.setClassid(Student.getClassid());
							ClassStudentImage.setClasses(Class.get(i).getGrade());
							ClassStudentImage.setLevel(Class.get(i).getClasses());
							ClassStudentImage.setContent(Student.getEvaluate());
							ClassStudentImage.setStudentName(Student.getName());
							ClassStudentImage.setImagePath(newIp+Student.getStudentimage());
							ClassStudentImage.setTitle(Student.getTitles());
							ListClassStudentImage.add(ClassStudentImage);
						}
						data.put("data", ListClassStudentImage);
						data.put("Total", Class.size());
						data.put("class", Class);
						data.put("success", false);
					}else {
						data.put("data", ListClassStudentImage);
						data.put("Total", null);
						data.put("class", Class);
						data.put("success", false);
					}
					
				}
			}else {
				classid=null;
				if (null !=name && name.length()>0) {
					pageIndex=(pageIndex-1)*pageSize;
					List<ClassStudentImage> ListClassStudentImage=new ArrayList<>();
					List<HljtClass> HljtClass=hljtClassServiceIpml.findClasslist();
					List<HljtStudent> Students=hljtStudentServiceImpl.findStudentName(name, null, null);
					List<HljtStudent> Student=hljtStudentServiceImpl.findStudentName(name, pageSize, pageIndex);
					if(null!=Student&&Student.size()>0) {
						for(int i=0;i<Student.size();i++) {
							ClassStudentImage ClassStudentImage=new ClassStudentImage();
							int Cid=Student.get(i).getClassid();
							HljtClass Class=hljtClassService.findClass(Cid);
							ClassStudentImage.setId(Student.get(i).getId()); 
							ClassStudentImage.setClassid(Student.get(i).getClassid());
							ClassStudentImage.setClasses(Class.getGrade());
							ClassStudentImage.setLevel(Class.getClasses());
							ClassStudentImage.setContent(Student.get(i).getEvaluate());
							ClassStudentImage.setStudentName(Student.get(i).getName());
							ClassStudentImage.setImagePath(newIp+Student.get(i).getStudentimage());
							ClassStudentImage.setTitle(Student.get(i).getTitles());
							ListClassStudentImage.add(ClassStudentImage);
						}
						data.put("data", ListClassStudentImage);
						data.put("Total", Students.size());
						data.put("class", HljtClass);
						data.put("success", false);
					}else {
						data.put("data", ListClassStudentImage);
						if(null!=Students&&Students.size()>0) {
							data.put("Total", Students.size());
						}else {
							data.put("Total", null);
						}
						data.put("class", HljtClass);
						data.put("success", false);
					}
				}else {
					pageIndex=(pageIndex-1)*pageSize;
					List<ClassStudentImage> ListClassStudentImage=new ArrayList<>();
					List<HljtStudent> Students=hljtStudentServiceImpl.findStudentAll();
					List<HljtClass> Class=hljtClassService.pageFindClassList(classid, pageSize, pageIndex,"1");
					List<HljtClass> HljtClass=hljtClassServiceIpml.findClasslist();
					if(null!=Class&&Class.size()>0) {
						for(int i=0;i<Class.size();i++) {
							ClassStudentImage ClassStudentImage=new ClassStudentImage();
							Integer id=Class.get(i).getStudentid();
							HljtStudent Student=hljtStudentServiceImpl.findStudent(id);
							ClassStudentImage.setId(Student.getId());
							ClassStudentImage.setClassid(Student.getClassid());
							ClassStudentImage.setClasses(Class.get(i).getGrade());
							ClassStudentImage.setLevel(Class.get(i).getClasses());
							ClassStudentImage.setContent(Student.getEvaluate());
							ClassStudentImage.setImagePath(newIp+Student.getStudentimage());
							ClassStudentImage.setStudentName(Student.getName());
							ClassStudentImage.setTitle(Student.getTitles());
							ListClassStudentImage.add(ClassStudentImage);
							
						}
						data.put("data", ListClassStudentImage);
						data.put("Total", Students.size());
						data.put("class", HljtClass);
						data.put("success",false);
					}else {
						data.put("data", ListClassStudentImage);
						if(null!=Students&&Students.size()>0) {
							data.put("Total", Students.size());
						}else {
							data.put("Total", null);
						}
						data.put("class", HljtClass);
						data.put("success", false);
					}
				}
			}
		}else {
			data.put("success", false);
		}
		Message.setData(data);
		return Message;
		}

	/**
	 * 班级之星添加接口
	 * @param studentid
	 * @param titles
	 * @param evaluate
	 * @param rep
	 * @return
	 * @throws IOException 
	 * @throws IllegalStateException 
	 */
	@RequestMapping("/addClassStudentImage")
	@ResponseBody
	public Message addClassStudentImage(String studentname,Integer classid,String titles,String evaluate,MultipartFile imgFile,HttpServletResponse rep) throws Exception{
		RepUtil.repPake(rep);
		Message Message=new Message();
		Map<String, Object> data =new HashMap<>();
		if(null !=studentname || null !=classid) {
			HljtStudent Student=hljtStudentServiceImpl.selectStudent(classid, studentname);
			if(null !=Student ) {
				HljtStudent hljtStudent=new HljtStudent();
				hljtStudent.setId(Student.getId());
				hljtStudent.setTitles(titles);
				hljtStudent.setEvaluate(evaluate);
				//生成新的图片名字
				String name = UUID.randomUUID().toString().replaceAll("-", "");
				//图片后缀名
				String ext = FilenameUtils.getExtension(imgFile.getOriginalFilename());
				//保存路径D:\java\apache-tomcat-8.0.48\webapps\image\class
				imgFile.transferTo(new File(WhetherNotToUpdate.getSaveDisk() + name + "." + ext));
				//新的图片名字
				String image=name+"."+ext;
				hljtStudent.setStudentimage(WhetherNotToUpdate.getReadDisk()+image);
				//修改学生表学生信息
				hljtStudentServiceImpl.updateStudents(hljtStudent);
				HljtClass hljtClass=new HljtClass();
				hljtClass.setId(Student.getClassid());
				hljtClass.setStudentid(Student.getId());
				//修改班级表班级之星信息
				hljtClassService.updateClass(hljtClass);
				hljtOtherInterfacesService.modifyByCalssId(classid);
				data.put("success", true);
			}else {
				data.put("success", false);
			}
		}else {
			data.put("success", true);
		}
		Message.setData(data);
		return Message;
	}
	
	/**
	 * 班级之星删除接口
	 * @param classid
	 * @param rep
	 * @return
	 */
	@RequestMapping("/deleteclassstudentimage")
	@ResponseBody
	public Message deleteClassStudentImage(Integer classid,HttpServletResponse rep){
		RepUtil.repPake(rep);
		Message Message=new Message();
		Map<String, Object> data =new HashMap<>();
		if (null !=classid) {
			HljtStudent hljtStudent=new HljtStudent();
			hljtStudent.setClassid(classid);
			hljtStudent.setTitles(null);
			hljtStudent.setEvaluate(null);
			hljtStudent.setStudentimage(null);
			
			hljtStudentServiceImpl.updateStudent(hljtStudent);
			HljtClass hljtClass=new HljtClass();
			hljtClass.setId(classid);
			hljtClass.setStudentid(null);
			hljtClassService.updateClass(hljtClass);
			hljtOtherInterfacesService.modifyByCalssId(classid);
			data.put("success", true);
		}else {
			data.put("success", false);
		}
		Message.setData(data);
		return Message;
	}
	
	/**
	 * 班级之星修改接口
	 * @param classid
	 * @param rep
	 * @return
	 * @throws IOException 
	 * @throws IllegalStateException 
	 */
	@RequestMapping("/updateClassStudentImage")
	@ResponseBody
	public Message updateClassStudentImage(String studentname,Integer classid,String titles,String evaluate,MultipartFile imgFile,HttpServletResponse rep) throws IOException{
		RepUtil.repPake(rep);
		Message Message=new Message();
		Map<String, Object> data =new HashMap<>();
		if(null !=studentname && null !=classid) {
			HljtStudent Student=hljtStudentServiceImpl.selectStudent(classid, studentname);
			HljtClass hljtClasses=hljtClassService.findClass(classid);
			Integer studentid=hljtClasses.getStudentid();
			if(null !=Student) {
				HljtStudent hljtStudents=new HljtStudent();
				hljtStudents.setClassid(classid);
				hljtStudents.setTitles(null);
				hljtStudents.setEvaluate(null);
				hljtStudents.setStudentimage(null);
				hljtStudentServiceImpl.updateStudent(hljtStudents);
				HljtStudent hljtStudent=new HljtStudent();
				hljtStudent.setId(Student.getId());
				hljtStudent.setTitles(titles);
				hljtStudent.setEvaluate(evaluate);
				if(imgFile.getSize()>0) {
					//生成新的图片名字
					String name = UUID.randomUUID().toString().replaceAll("-", "");
					//图片后缀名
					String ext = FilenameUtils.getExtension(imgFile.getOriginalFilename());
					//保存路径D:\java\apache-tomcat-8.0.48\webapps\image\class
					imgFile.transferTo(new File(WhetherNotToUpdate.getSaveDisk() + name + "." + ext));
					//新的图片名字
					String image=name+"."+ext;
					
					hljtStudent.setStudentimage(WhetherNotToUpdate.getReadDisk()+image);
				}else {
					hljtStudent.setStudentimage(Student.getStudentimage());
				}
				//修改学生表学生信息
				hljtStudentServiceImpl.updateStudents(hljtStudent);
				HljtClass hljtClass=new HljtClass();
				hljtClass.setId(Student.getClassid());
				hljtClass.setStudentid(Student.getId());
				//修改班级表班级之星信息
				hljtClassService.updateClass(hljtClass);
				hljtOtherInterfacesService.modifyByCalssId(classid);
				data.put("success", true);
			}else {
				data.put("success", false);
}
			
		}else {
			data.put("success", true);
		}
		Message.setData(data);
		return Message;
		}
	
	/**
	 * 班级课程表查询接口
	 * @param classid
	 * @param rep
	 * @return
	 */
	@RequestMapping("/selectclassschedulecard")
	@ResponseBody
	public Message selectClasssCheduleCard(Integer classid,HttpServletResponse rep){
		RepUtil.repPake(rep);
		Message Message=new Message();
		Map<String, Object> data =new HashMap<>();
		if(null !=classid) {
			if(classid>-1) {
				List<HljtClass> Classes=hljtClassService.pageFindClassList(classid, null, null,null);
				List<ClasssCheduleCard> classsCheduleCardList=new ArrayList<>();
				//通过班级id查找对应班级信息
				HljtClass Class=hljtClassService.findClass(classid);
				if(null !=Class) {
					Integer Gradeid=Class.getGradeid();
					List<HljtGradetime> Gradetime=hljtGradetimeServiceImpl.findGradetime(Gradeid);
					//查找对应班级课程表
					List<HljtClassschedulecard> Classschedulecard=hljtClassschedulecardServiceImpl.findClassschedulecard(classid);
					if(null!=Classschedulecard&& Classschedulecard.size()>0&&null!=Gradetime&&Gradetime.size()>0) {
						
						for(int i=0;i<Classschedulecard.size();i++) {
							ClasssCheduleCard classsCheduleCard=new ClasssCheduleCard();
							//课程名字
							if(null !=Classschedulecard.get(i).getFriday()&&Classschedulecard.get(i).getFriday().length()>0) {
								classsCheduleCard.setFriday(Classschedulecard.get(i).getFriday());
								String teacherNameFriday =hljtTeacherclassServiceImpl.selsectTeacherName(classid, Classschedulecard.get(i).getFriday());
								//课程老师名字
								classsCheduleCard.setFridayteachername(teacherNameFriday);
							}else {
								classsCheduleCard.setFriday("");
								classsCheduleCard.setFridayteachername("");
							}
							if(null !=Classschedulecard.get(i).getMonday()&&Classschedulecard.get(i).getMonday().length()>0) {
								classsCheduleCard.setMonday(Classschedulecard.get(i).getMonday());
								String teacherNameMonday =hljtTeacherclassServiceImpl.selsectTeacherName(classid, Classschedulecard.get(i).getMonday());
								classsCheduleCard.setMondayteachername(teacherNameMonday);
							}else {
								classsCheduleCard.setMonday("");
								classsCheduleCard.setMondayteachername("");
							}
							if(null !=Classschedulecard.get(i).getSaturday()&& Classschedulecard.get(i).getSaturday().length()>0) {
								classsCheduleCard.setSaturday(Classschedulecard.get(i).getSaturday());
								String teacherNameSaturday =hljtTeacherclassServiceImpl.selsectTeacherName(classid, Classschedulecard.get(i).getSaturday());
								classsCheduleCard.setSaturdayteachername(teacherNameSaturday);
							}else {
								classsCheduleCard.setSaturday("");
								classsCheduleCard.setSaturdayteachername("");
							}
							if(null !=Classschedulecard.get(i).getSunday()&&Classschedulecard.get(i).getSunday().length()>0) {
								classsCheduleCard.setSunday(Classschedulecard.get(i).getSunday());
								String teacherNameSunday =hljtTeacherclassServiceImpl.selsectTeacherName(classid, Classschedulecard.get(i).getSunday());
								classsCheduleCard.setSundayteachername(teacherNameSunday);
							}else{
								classsCheduleCard.setSunday("");
								classsCheduleCard.setSundayteachername("");
							}
							if(null !=Classschedulecard.get(i).getThursday()&&Classschedulecard.get(i).getThursday().length()>0) {
								classsCheduleCard.setThursday(Classschedulecard.get(i).getThursday());
								String teacherNameThursday =hljtTeacherclassServiceImpl.selsectTeacherName(classid, Classschedulecard.get(i).getThursday());
								classsCheduleCard.setThursdayteachername(teacherNameThursday);
							}else {
								classsCheduleCard.setThursday("");
								classsCheduleCard.setThursdayteachername("");
							}
							if(null != Classschedulecard.get(i).getTuesday()&&Classschedulecard.get(i).getTuesday().length()>0) {
								classsCheduleCard.setTuesday(Classschedulecard.get(i).getTuesday());
								String teacherNameTuesday =hljtTeacherclassServiceImpl.selsectTeacherName(classid, Classschedulecard.get(i).getTuesday());
								classsCheduleCard.setTuesdayteachername(teacherNameTuesday);
							}else {
								classsCheduleCard.setTuesday("");
								classsCheduleCard.setTuesdayteachername("");
							}
							if(null !=Classschedulecard.get(i).getWednesday()&&Classschedulecard.get(i).getWednesday().length()>0) {
								classsCheduleCard.setWednesday(Classschedulecard.get(i).getWednesday());
								String teacherNameWednesday =hljtTeacherclassServiceImpl.selsectTeacherName(classid, Classschedulecard.get(i).getWednesday());
								classsCheduleCard.setWednesdayteachername(teacherNameWednesday);
							}else {
								classsCheduleCard.setWednesday("");
								classsCheduleCard.setWednesdayteachername("");
							}
							classsCheduleCard.setQualifying(i+1);
							classsCheduleCard.setEndtime(Gradetime.get(i).getEndtime());
							classsCheduleCard.setStarttime(Gradetime.get(i).getStarttime());
							
							classsCheduleCardList.add(classsCheduleCard);
							data.put("classschedulecard", classsCheduleCardList);
						}
					}else {
						for(int i=0;i<Gradetime.size();i++) {
							ClasssCheduleCard classsCheduleCard=new ClasssCheduleCard();
								classsCheduleCard.setFriday("");
								classsCheduleCard.setFridayteachername("");
								classsCheduleCard.setMonday("");
								classsCheduleCard.setMondayteachername("");
								classsCheduleCard.setSaturday("");
								classsCheduleCard.setSaturdayteachername("");
								classsCheduleCard.setSunday("");
								classsCheduleCard.setSundayteachername("");
								classsCheduleCard.setThursday("");
								classsCheduleCard.setThursdayteachername("");
								classsCheduleCard.setTuesday("");
								classsCheduleCard.setTuesdayteachername("");
								classsCheduleCard.setWednesday("");
								classsCheduleCard.setWednesdayteachername("");
							classsCheduleCard.setQualifying(i+1);
							classsCheduleCard.setEndtime(Gradetime.get(i).getEndtime());
							classsCheduleCard.setStarttime(Gradetime.get(i).getStarttime());
							
							classsCheduleCardList.add(classsCheduleCard);
							data.put("classschedulecard", classsCheduleCardList);
						}
							
					}
					List<String> teacherName =hljtTeacherServiceImpl.findTeacherName(classid);
					List<HljtSubject> SubjectList=hljtSubjectServiceImpl.findSubject();
					data.put("classes", Classes);
					data.put("teacherName", teacherName);
					data.put("Subject", SubjectList);
					data.put("success", "SUCCESS");
				}else {
					data.put("classes", Classes);
					data.put("teacherName", null);
					data.put("Subject", null);
					data.put("success", "SUCCESS");
				}
			}else {
				List<HljtClass> HljtClass=hljtClassServiceIpml.findClasslist();
				data.put("classes", HljtClass);
			}
		}else {
			data.put("success", "SUCCESS");
		}
		
		Message.setData(data);
		return Message;
	}
	
	/**
	 * 班级课程表添加
	 * @param classschedulecard
	 * @param rep
	 * @return
	 */
	@RequestMapping("/addclassschedulecard")
	@ResponseBody
	public Message addClasssCheduleCard(String classschedulecard,HttpServletResponse rep){
		RepUtil.repPake(rep);
		Message Message=new Message();
		Map<String, Object> data =new HashMap<>();
		if(null !=classschedulecard && classschedulecard.length()>0) {
			JSONObject json = JSONObject.fromObject(classschedulecard);  
			List<JSONObject> list=json.getJSONArray("Classschedulecard");
			Integer calssid=Integer.parseInt(json.getString("classid"));
			List<HljtClassschedulecard> Classschedulecard=hljtClassschedulecardServiceImpl.findClassschedulecard(calssid);
			if(Classschedulecard.size()>0 && null !=Classschedulecard) {
				for(int i=0;i<list.size();i++) {
					HljtClassschedulecard HljtClassschedulecard=new HljtClassschedulecard();
					HljtClassschedulecard.setClassid(calssid);
					HljtClassschedulecard.setQualifying(i+1);
					HljtClassschedulecard.setMonday(list.get(i).getString("monday"));
					HljtClassschedulecard.setTuesday(list.get(i).getString("tuesday"));
					HljtClassschedulecard.setWednesday(list.get(i).getString("wednesday"));
					HljtClassschedulecard.setThursday(list.get(i).getString("thursday"));
					HljtClassschedulecard.setFriday(list.get(i).getString("friday"));
					HljtClassschedulecard.setSaturday(list.get(i).getString("saturday"));
					HljtClassschedulecard.setSunday(list.get(i).getString("sunday"));
					hljtClassschedulecardServiceImpl.updateClassschedulecard(HljtClassschedulecard);
				}
				hljtOtherInterfacesService.modifyByCalssId(calssid);
				data.put("success", true);
			}else {
				for(int i=0;i<list.size();i++) {
					HljtClassschedulecard HljtClassschedulecard=new HljtClassschedulecard();
					HljtClassschedulecard.setClassid(calssid);
					HljtClassschedulecard.setQualifying(i+1);
					HljtClassschedulecard.setMonday(list.get(i).getString("monday"));
					HljtClassschedulecard.setTuesday(list.get(i).getString("tuesday"));
					HljtClassschedulecard.setWednesday(list.get(i).getString("wednesday"));
					HljtClassschedulecard.setThursday(list.get(i).getString("thursday"));
					HljtClassschedulecard.setFriday(list.get(i).getString("friday"));
					HljtClassschedulecard.setSaturday(list.get(i).getString("saturday"));
					HljtClassschedulecard.setSunday(list.get(i).getString("sunday"));
					hljtClassschedulecardServiceImpl.addClassschedulecard(HljtClassschedulecard);
				}
				hljtOtherInterfacesService.modifyByCalssId(calssid);
				data.put("success", true);
			}
		}else {
			data.put("success", false);
		}
		Message.setData(data);
		return Message;
		}
	
	
	
	/*
	 public static final String getIp() throws Exception {
	        String ipString = "";
	        Enumeration<NetworkInterface> allNetInterfaces = NetworkInterface.getNetworkInterfaces();
	        InetAddress ip = null;
	        while (allNetInterfaces.hasMoreElements()) {
	            NetworkInterface netInterface = (NetworkInterface) allNetInterfaces.nextElement();
	            Enumeration<InetAddress> addresses = netInterface.getInetAddresses();
	            while (addresses.hasMoreElements()) {
	                ip = (InetAddress) addresses.nextElement();
	                if (ip != null && ip instanceof Inet4Address && !ip.getHostAddress().equals("127.0.0.1")) {
	                    return ip.getHostAddress();
	                }
	            }
	        }
	        return ipString;
	    }*/
}
